xen init script: Do nothing if running for wrong Xen package
authorIan Jackson <ian.jackson@citrix.com>
Thu, 7 Feb 2019 15:56:49 +0000 (15:56 +0000)
committerHans van Kranenburg <hans@knorrie.org>
Wed, 13 Feb 2019 00:07:36 +0000 (01:07 +0100)
See the big comment.  We think that this is responsible for various
bugs and, particularly, reports of mysteriously missing xenconsoled.

For example, this bug would mean that after a Xen version upgrade,
autoremoval of an obsolete xen-utils-V package would stop the running
xenconsoled.  This is obviously awkward to track down, and could occur
many weeks or months after the upgrade.

Closes: #851654
Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Hans van Kranenburg <hans@knorrie.org>
debian/xen-utils-common.xen.init

index da7d361453102341e0bd577c25c8e243dcc22d7d..b0df7be8abe62c3255f53af1a8c76aa93b653d60 100644 (file)
@@ -24,6 +24,35 @@ case "$(cat /sys/hypervisor/type 2>/dev/null)" in
 xen)           ;;
 *)     exit 0  ;; # not running under Xen
 esac
+
+VERSION=$(/usr/lib/xen-common/bin/xen-version)
+
+# The arrangements for the `xen' init script are a bit odd.
+# This script is part of xen-utils-common, of which there is one
+# version installed regardless of the Xen version.
+#
+# But it is called by the prerm and postinsts of xen-utils-VERSION.
+# The idea is that (for example) if xen-utils-VERSION is upgraded, the
+# daemons are restarted.
+#
+# However, this means that this script may be called by the
+# maintscript of a xen-utils-V package for a different V to the
+# running version of Xen (X, say).  Such a xen-utils-V package does
+# not actually want to start or stop its daemons.  Indeed, the version
+# selection machinery would redirect its efforts to the xen-utils-X
+# utilities.  But this is not right: we don't actually want to (for
+# example) stop xenconsoled from xen-utils-X just because some
+# not-currently-relevant xen-utils-V is installed/removed/whatever.
+#
+# So we use DPKG_MAINTSCRIPT_PACKAGE to detect this situation, and
+# turn these extraneous calls into no-ops.
+
+case $DPKG_MAINTSCRIPT_PACKAGE in
+xen-utils-$VERSION)    ;;      # xen-utils-V maintscript, under Xen X=V
+xen-utils-*)           exit 0;; # xen-utils-V maintscript, but under Xen X!=V
+*)                     ;;      # maybe not under dpkg, etc.
+esac
+
 ROOT=$(/usr/lib/xen-common/bin/xen-dir 2>/dev/null)
 if [ $? -ne 0 ]; then
        log_warning_msg "Not running within Xen or no compatible utils"